package com.wfh.blog.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer{

    //定义不拦截路径 就是要登录的页面不排除 登录的提交方式不排除 以及静态资源不拦截
    private static final String[] excludePaths = {"/admin", "/admin/login", "/static/**"};

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()) //与LoginInterceptor关联起来
                .addPathPatterns("/admin/**")  //拦截后台的所有页面
                .excludePathPatterns(excludePaths);

    }
}
